package com.ruoyi.erp.common.enums;

/**
 * @author qwc
 * @Date 2022/1/13 11:40
 */
public enum ProductType {

    PRODUCT("0", "产品"),

    MATERIAL("1", "材料"),

    TOOL("2", "工具"),

    OTHER("3", "其它");

    private final String key;
    private final String value;

    ProductType(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getValueByKey(String key) {
        for (ProductType productType : ProductType.values()) {
            if (productType.getKey().equals(key)) {
                return productType.getValue();
            }
        }
        return null;
    }

    public String getKey() {
        return this.key;
    }

    public String getValue() {
        return this.value;
    }

    public static String getKeyByValue(String value) {
        for (ProductType productType : ProductType.values()) {
            if (productType.getValue().equals(value)) {
                return productType.getKey();
            }
        }
        return null;
    }

}
